#!/usr/env/bin python
# -*- coding: utf-8 -*-

# @Time    : 2019/12/31 09:35|09:35
# @Author  : yangdingyi
# @File    : myexec
# @Software: PyCharm


class BaseError(Exception):

    def __init__(self, message):
        self.message = message


class WrongError(BaseError):
    pass


data = """
data_list = [
    (123, 322),
    (234, 432),
    (45, 53),
]
"""

code = """
class Solution:
    def reverse(self, x: int) -> int:
        ans = 0
        while x:
            ans = ans * 10 + x % 10
            x //= 10    
        return ans
"""
# TODO 运行错误检测
# wrong, time out, stack ...
run = """
solve = Solution()
for i, (data, ans) in enumerate(data_list):
    print(i, data, ans)
    ret = solve.reverse(data)
    if not (ret == ans):
        msg = 'wrong[{}]: {} vs {}'.format(i, ret, ans)
        raise WrongError(msg)
    else:
        print('accept[{}]'.format(i))
"""

exec(data)
exec(code)
try:
    exec(run)
except WrongError as e:
    print('except:', e)
